package Java.com.wang.string01;

public class string {
    private int maxSize = 30;
    private char[] chars;
    private int length;

    public string(int n) {
        this.maxSize = n;
        this.chars = new char[n];
        this.length = 0;
    }

    public void ip(char[] c,int n) {
        this.maxSize=n;
        this.chars=new char[n];
        this.length=0;
        //this.length = c.length;
        for (int i = 0; i < c.length; i++) {
            if (c[i] == '\0') {
                break;
            }
            this.chars[this.length] = c[i];
            this.length++;
        }
    }

    public void iplus(char[] c) {
        int i;
        for (i = 0; i < c.length; i++) {
            if (c[i] == '\0') {
                break;
            }
            this.chars[this.length] = c[i];
            this.length++;
        }
    }

    public void numb() {
        int i = 0;
        int a, b, c, d;
        a = b = c = d = 0;
        for (i = 0; i < this.length; i++) {
            if ((96 < this.chars[i]) & (123 > this.chars[i])) {
                a = a + 1;
            } else if ((64 < this.chars[i]) & (91 > this.chars[i])) {
                b = b + 1;
            } else if ((47 < this.chars[i]) & (58 > this.chars[i])) {
                c = c + 1;
            } else {
                d = d + 1;
            }
        }
        System.out.println("该字符串中共有小写字母" + a + "个");
        System.out.println("该字符串中共有大写字母" + b + "个");
        System.out.println("该字符串中共有数字" + c + "个");
        System.out.println("该字符串中共有其他字符" + d + "个");
        System.out.println("该字符串中共有字符" + (a + b + c + d) + "个");
    }

    public void numbplus() {
        int i, w, x, y, z;
        i = w = x = y = z = 0;
        char[] a = new char[10];
        char[] b = new char[10];
        char[] c = new char[10];
        char[] d = new char[10];

        for (i = 0; i < this.length; i++) {
            if ((96 < this.chars[i]) & (123 > this.chars[i])) {
                a[w] = this.chars[i];
                w++;
            } else if ((64 < this.chars[i]) & (91 > this.chars[i])) {
                b[x] = this.chars[i];
                x++;
            } else if ((47 < this.chars[i]) & (58 > this.chars[i])) {
                c[y] = this.chars[i];
                y++;
            } else {
                d[z] = this.chars[i];
                z++;
            }
        }
        this.ip(a,50);
        this.iplus(b);
        this.iplus(c);
        this.iplus(d);
        this.display();
    }

    public void display() {
        for (int j = 0; j < this.length; j++) {
            System.out.println(this.chars[j]);
        }
    }

}